﻿using B.Auth.APi.Application.Command.Users;
using B.Auth.Domain.Entity;
using B.Auth.Domain.Repository;
using B.Auth.Enum;
using MediatR;
using System.Reflection.Metadata.Ecma335;

namespace B.Auth.APi.Application.CommandHand
{
    public class GetCountrycommandHand : IRequestHandler<GetCountrycommand, ApiResult<List<County>>>
    {
        private readonly IBaseRepository<County> db;

        public GetCountrycommandHand(IBaseRepository<County> db)
        {
            this.db = db;
        }

        public Task<ApiResult<List<County>>> Handle(GetCountrycommand request, CancellationToken cancellationToken)
        {
            var result=new ApiResult<List<County>>();
            var m = db.GetAll().Where(x => x.cityid == request.cityid);
            result.data= m.ToList();
            return Task.FromResult(result);
        }
    }
}
